package com.jasmine;

import com.jasmine.limit.RateLimiterInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.PostConstruct;


/**
 * @author jasmineXz
 */
public class ApiMvcConfig implements WebMvcConfigurer {
    private static final Logger log = LoggerFactory.getLogger(ApiMvcConfig.class);

    @Autowired
    private RateLimiterInterceptor apiLimiterInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(apiLimiterInterceptor).addPathPatterns("/**");
    }

    @PostConstruct
    public void init() {
        log.info("[BJSTK] [COMMON API MANAGER] ApiMvcConfig Initialization completed");
    }

}